package com.example.gkgyservice.controller;

import com.example.gkgyservice.domain.AddDataVo;
import com.example.gkgyservice.domain.OpcUaServer;
import com.example.gkgyservice.service.OpcUaSocketService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.*;

import java.util.List;
import java.util.Map;

/**
 * @author:xec
 * @date:2022/12/5 11:00
 **/
@RestController
@RequestMapping("/opcUaSocket")
public class OpcUaSocketController {

    @Autowired
    OpcUaSocketService opcUaSocketService;

    @PostMapping("/editValue")
    public Map<String,Object> editValue(@RequestBody List<OpcUaServer> opcUaServerList){
        return opcUaSocketService.editValue(opcUaServerList);
    }

    @PostMapping("/addData/{uid}")
    @ResponseBody
    public Map<String,Object> addData(@RequestBody List<AddDataVo> addDataVos, @PathVariable("uid") String uid){
        return opcUaSocketService.addData(addDataVos,uid);
    }

    @GetMapping("/flag")
    public void editFlag(Integer value){
        opcUaSocketService.editFlag(value);
    }

    @ResponseBody
    @GetMapping("/list")
    public List<OpcUaServer> list(OpcUaServer opcUaServer){
        return opcUaSocketService.list(opcUaServer);
    }

    @GetMapping("/selectByName")
    @ResponseBody
    public OpcUaServer selectByName(String uid,String name){
        OpcUaServer opcUaServer = opcUaSocketService.selectByName(uid, name);
        return opcUaServer;
    }
}
